hysop.core.memory.buffer module¶
- class hysop.core.memory.buffer.Buffer(size, **kwds)[source]¶
Bases:
object
Base class for releasable buffers. A buffer should just offer a release method to be compatible with allocators.
Host buffers are numpy buffers. Cuda and OpenCl buffers are the one provided by pycuda and pyopencl.
Buffers should be obtained through allocators or memory pools.
- abstract aligned_view(alignment, size=None)[source]¶
Return a view of this buffer with an offset such that the returned buffer is now aligned on min_alignment and has now given size.
- property buf¶
- classmethod from_int_ptr(int_ptr_value, **kargs)[source]¶
Constructs a pyopencl handle from a C-level pointer (given as the integer int_ptr_value). If the previous owner of the object owns the handle and will not release it, on can set retain to False, to effectively transfer ownership. Setting retain to True should increase an implementation specific reference counter. The buffer will be freed when buffer reference counter is 0.
- abstract release()[source]¶
Release this buffer (decrease internal implementation defined reference counter).
- property size¶
- class hysop.core.memory.buffer.PooledBuffer(pool, buf, alloc_sz, size, alignment, **kwds)[source]¶
Bases:
Buffer
Memory pool allocated buffer wrapper.
Create a memory pool wrapped buffer. Input buffer buf was allocated by given pool with real size alloc_sz. Buffer is resized and aligned to given size and alignment. On destruction, buffer will be given back to the pool.
- aligned_view(alignment, size=None)[source]¶
Return a view of this buffer with an offset such that the returned buffer is now aligned on min_alignment and has now given size.
- property buf¶
Get wrapped buffer handle.
- property int_ptr¶
Get wrapped buffer handle pointer as an int.
- property pool¶
Get pool that allocated this buffer.